package com.sinosoft.bee.services.cousumerwithfeign.demo.controller;

import com.sinosoft.bee.services.cousumerwithfeign.demo.annotations.WrongSample;
import com.sinosoft.bee.services.cousumerwithfeign.demo.interfaces.BeeProviderDemoService;
import com.sinosoft.bee.services.cousumerwithfeign.demo.service.impl.UserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author:TobbyQuinn
 * @date:2018/4/26
 * @project:bee
 **/
@RestController
public class DemoController {


    @Autowired
    private BeeProviderDemoService service;

    @Autowired
    private UserServiceImpl userService;

    /**
     * 测试前get,后get
     * 结果：成功
     * @param id
     * @return
     */
    @GetMapping("/consumer/{id}")
    public ResultVO getConsumer1(@PathVariable long id){
        return service.getFromProvider1(id);
    }
    /**
     * 测试前get,后post
     * 结果：失败，Request method }POST} not supported","path":"/provider/1"
     * @param id
     * @return
     */
    @GetMapping("/consumer2/{id}")
    @WrongSample
    public ResultVO getConsumer2(@PathVariable long id){
        return service.getFromProvider2(id);
    }

    @GetMapping("/consumer3/{id}")
    @WrongSample
    public ResultVO getConsumer3(@PathVariable long id){
        return service.getFromProvider3(id);
    }

    public void testPage(){
        userService.getUserByPage(1,1);
    }
}
